Skip to content

Do not consume statement terminator in unparenthesized option lists#2376

Open
LucaCappelletti94 wants to merge 1 commit into
apache:mainfrom
LucaCappelletti94:create-user-consumes-terminator
Open

Do not consume statement terminator in unparenthesized option lists#2376
LucaCappelletti94 wants to merge 1 commit into
apache:mainfrom
LucaCappelletti94:create-user-consumes-terminator

Conversation

@LucaCappelletti94

@LucaCappelletti94 LucaCappelletti94 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

CREATE USER <name> and ALTER USER <name> SET ... parse on their own, but CREATE USER user1; SELECT 1 (and the two ALTER USER ... SET forms) fail with Expected: end of statement, found: SELECT. The trailing option list is read by parse_key_value_options, whose loop drives on next_token() and breaks on a ; that it has already consumed. With the terminator gone, the top-level statement loop sees the next statement's first token directly and errors out. The bug is dialect independent and affects every unparenthesized caller of the helper: CREATE USER and both ALTER USER ... SET branches. Statements that never reach the helper (CREATE ROLE, DROP USER, ALTER USER ... RENAME) are unaffected, as are the parenthesized callers, which end on ).

This puts the semicolon back with prev_token() before breaking, so the caller and the top-level loop still see the separator, mirroring how the existing end-keyword arm already does it. The EOF arm needs no rewind. Fixing the single helper repairs all three statements at once. A regression test parses each of the three forms followed by SELECT 1 and asserts two statements result.

@LucaCappelletti94 LucaCappelletti94 force-pushed the create-user-consumes-terminator branch from a2faf7b to dabfe2b Compare June 11, 2026 14:21
@LucaCappelletti94 LucaCappelletti94 changed the title Do not consume statement terminator in CREATE USER option list Do not consume statement terminator in unparenthesized option lists Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant